Skip to content

Conversation

@astei
Copy link
Contributor

@astei astei commented Feb 14, 2025

Change Summary

Adds support for validating v6 and v8 UUIDs. UUID version 6 and 8 defined in RFC 9562.

Upon request from from @Viicos on pydantic/pydantic#11436, creating this PR to wire up UUID v6 and v8 validation support.

Related issue number

n/a

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

@codecov
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.55%. Comparing base (ab503cb) to head (7b2e241).
Report is 293 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1636      +/-   ##
==========================================
- Coverage   90.21%   89.55%   -0.67%     
==========================================
  Files         106      115       +9     
  Lines       16339    17920    +1581     
  Branches       36       25      -11     
==========================================
+ Hits        14740    16048    +1308     
- Misses       1592     1853     +261     
- Partials        7       19      +12     
Files with missing lines Coverage Δ
python/pydantic_core/core_schema.py 95.08% <ø> (+0.31%) ⬆️
src/validators/uuid.rs 98.64% <100.00%> (+0.05%) ⬆️

... and 64 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 741961c...7b2e241. Read the comment docs.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 14, 2025

CodSpeed Performance Report

Merging #1636 will not alter performance

Comparing astei:astei/add-uuidv6v8 (7b2e241) with main (741961c)

Summary

✅ 157 untouched benchmarks

@astei
Copy link
Contributor Author

astei commented Feb 14, 2025

please review

@Viicos
Copy link
Member

Viicos commented Feb 14, 2025

Thanks @astei. Is it possible to also update this comment?

// This block checks if the UUID version matches the expected version and
// if the UUID variant conforms to RFC 4122. When dealing with Python inputs,
// UUIDs must adhere to RFC 4122 standards.
if let Some(expected_version) = self.version {
if uuid.get_version_num() != expected_version || uuid.get_variant() != Variant::RFC4122 {
return Err(ValError::new(
ErrorType::UuidVersion {
expected_version,
context: None,
},

With something along the lines of:

This block checks if the UUID version matches the expected version and
if the UUID variant conforms to RFC 9562 (superseding RFC4122) . When dealing with Python inputs,
UUIDs must adhere to RFC 9562 standards.

@Viicos Viicos changed the title Add support for UUIDv6 and UUIDv8 validation as well Add support for UUIDv6 and UUIDv8 validation Feb 14, 2025
Copy link
Member

@Viicos Viicos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Viicos Viicos merged commit a0e60bd into pydantic:main Feb 17, 2025
28 of 29 checks passed
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 20, 2025
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants